﻿@page "/dicttype"
@using daonaite.ui.Util
@using daonaite.ui.Api
@using daonaite.Model.system.dictType
@using daonaite.Model
@inject HttpHelp http
@inject RulesHelp rule
@inject apiDicttype dtypeurl

<Card>
    <Form Model="@queryform" Layout="@FormLayout.Inline" OnFinish="queryfinish">
        <FormItem Label="字典名称">
            <Input @bind-Value="@context.dictname"></Input>
        </FormItem>
        <FormItem>
            <Button Type="@ButtonType.Primary" HtmlType="submit">搜索</Button>
        </FormItem>
    </Form>
</Card>
<Card>
    <Button>新增</Button>
    <Button>编辑</Button>
    <Button>删除</Button>
    <Button>导入</Button>
    <Button>导出</Button>
</Card>
<Card>
    <Table DataSource="@table" @bind-SelectedRows="@selects" RemoteDataSource @bind-Total="@queryform.total" 
    @bind-PageIndex = "@queryform.pageIndex" @bind-PageSize="@queryform.pageSize">
        <Selection></Selection>
        <PropertyColumn Property="c=>c.id" Title="序号"></PropertyColumn>
        <PropertyColumn Property="c=>c.dictname" Title="字典名称"></PropertyColumn>
        <PropertyColumn Property="c=>c.biaoshi" Title="字典标识">
            <Button>
                @context.biaoshi
            </Button>
        </PropertyColumn>
        <ActionColumn>
            <Button>编辑</Button>
            <Button>删除</Button>
        </ActionColumn>
    </Table>
</Card>

@code {
    private Dto_dicttype queryform = new Dto_dicttype();

    private List<sys_dicttype> table = new List<sys_dicttype>();
    private IEnumerable<sys_dicttype> selects = new List<sys_dicttype>();

    private Modals<sys_dicttype> dicttype = new Modals<sys_dicttype>();

    protected override async Task OnInitializedAsync()
    {
        await queryfinish();
        await base.OnInitializedAsync();
    }

    private async Task queryfinish()
    {
        var result = await http.posttAsync<List<sys_dicttype>?, Dto_dicttype>(dtypeurl.select, queryform);
        if (result.Code == 200)
        {
            queryform.total = result.totalcount;
            queryform.pageSize = result.pageSize;
            queryform.pageIndex = result.pageindex;
            table = result.Data;
        }
    }
}
